import datetime
from typing import Union

from pydantic import BaseModel
from sqlalchemy import JSON


class TaskSchema(BaseModel):
    id: Union[int, None]
    script: int
    name: str
    cron: str
    status: Union[str, None]
    args: Union[list, None]
    recount: Union[int, None]
    delay: Union[str, None]
    enable: bool
    username: Union[str, None]
    last_status: Union[int, None]
    next_time: Union[datetime.datetime, None]

    class Config:
        orm_mode = True


class TaskUpdateSchema(BaseModel):
    id: str
    script: str
    name: str
    cron: str
    status: Union[str, None]
    enable: bool
    args: Union[list, None]
    recount: Union[int, None]
    last_status: Union[bool, None]
    next_time: Union[str, None]
    delay: Union[str, None]
    username: Union[str, None]
